<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "/common/header.ftl">
    <title>活动管理</title>
</head>
<body>
	<form id="edit_activity_form"  method="post">
	    <input type="hidden" id="editFlag" value="${editFlag}">
	    <input type="hidden" id="id" name="id" value="${activityInfoVo.id}">
	    <input type="hidden" name="ltId" id="userInfoId" value="">
	    <input type="hidden" id="actVersion" name="version" value="${activityInfoVo.version }">
	    <input type="hidden" id="ltVersion" name="ltVersion" value="">
	    <input type="hidden" id="tempStatus" name="ltVersion" value="${activityInfoVo.status }">
	    <input type="hidden" id="investType" value="${activityInfoVo.investType }">
	    <input type="hidden" name="rewardPoint" value="20">
	    <table class="formTable" id="add_activity_Tab">
	         <tr>
	             <td align="right" class="label"> 标题：</td>
	             <td class="value">
	                <input name="" id="title" data-options="required:true" class="easyui-validatebox" onblur="searchActTitle();" value="${activityInfoVo.title }"/>
	             </td>
	         </tr>
	         <tr>
	 		  	<td class="label">发布平台：</td>
	 			<td class="value" colspan="3">
	 				<input id="publishPlatforms" type="hidden" name="publishPlatforms" value="${activityInfoVo.publishPlatforms }"/>
	 				<input id="publishPlatforms1" value="1" type="checkbox" onclick="return false;" class="easyui-validatebox" />PC
	 				<input id="publishPlatforms2" value="2" type="checkbox" onclick="return false;" class="easyui-validatebox" />APP
	 				<input id="publishPlatforms3" value="3" type="checkbox" onclick="return false;" class="easyui-validatebox" />触屏版
	 			</td>
	 		</tr>
	 		<tr>
	  		  	<td class="label">可投标类型：</td>
	  			<td class="value" colspan="3">
	  				<input id="borrowTypes" type="hidden" name="borrowTypes" value="${activityInfoVo.borrowTypes}"/>
	  				<input id="borrowTypes1" value="3" type="checkbox" onclick="return false;" class="easyui-validatebox"/>新手标
	  				<input id="borrowTypes2" value="1" type="checkbox" onclick="return false;" class="easyui-validatebox"/>活期宝
	  				<input id="borrowTypes3" value="2" type="checkbox" onclick="return false;" class="easyui-validatebox"/>优选计划
	  				<input id="borrowTypes4" value="0" type="checkbox" onclick="return false;" class="easyui-validatebox"/>散标
	  				<input id="borrowTypes5" value="5" type="checkbox" onclick="return false;" class="easyui-validatebox"/>游艇
	  				<input id="borrowTypes6" value="6" type="checkbox" onclick="return false;" class="easyui-validatebox"/>酒店
	  				<input id="borrowTypes8" value="8" type="checkbox" onclick="return false;" class="easyui-validatebox"/>秒借
	  				<input id="borrowTypes9" value="9" type="checkbox" onclick="return false;" class="easyui-validatebox"/>有用分期
	  				<input id="borrowTypes99" value="99" type="checkbox" onclick="return false;" class="easyui-validatebox"/>集合包
	  			</td>
	  		</tr>
	  		<tr>
	            <td class="label">投资类型：</td>
	            <td class="value">
	               <input class="easyui-validatebox" style="width: 240px" readonly="readonly" id="investTypeName"/>
	            </td>
	        </tr>
	        <tr>
	           <td class="label">投资金额：</td>
	           <td class="value">
	           	<input class="easyui-numberbox" style="width: 240px" value="${activityInfoVo.investAmount}" readonly="readonly"/>元
	           </td>
	       </tr>
	       <tr>
	             <td align="right" class="label">奖池ID：</td>
	             <td class="value">
	            	 <input id="ticketId" class="easyui-validatebox" readonly="readonly" value="${activityInfoVo.ticketId }" />
	             </td>
			</tr>
			<tr>
			    <td align="right"  class="label">活动开始时间：</td>
			    <td class="value">
			    	<input name="registerStart"  class="easyui-datetimebox" style="width: 240px" data-options="required:true"
			    	value="<fmt:formatDate value='${activityInfoVo.registerStart }' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
			    </td>
			</tr>
			<tr>
			    <td align="right" class="label">活动结束时间：</td>
			    <td class="value">
			    	<input name="registerEnd"  class="easyui-datetimebox" style="width: 240px" data-options="required:true" 
			    	value="<fmt:formatDate value='${activityInfoVo.registerEnd }' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
			    </td>
			</tr>
			<tr id="ltTempStoreTR">
			    <td colspan="2">
			    </td>
			</tr>
			<tr>
			    <td align="right" class="label"> 活动介绍：</td>
			    <td class="value">
			       <textarea name="" rows="" cols="">${activityInfoVo.introduction }</textarea>
			    </td>
			</tr>
			<tr>
			    <td align="right" class="label"> 状态：</td>
			    <td class="value">
			    	<select name="status" id="status" data-options="required:true">
			          <option value="1">生效</option>
			          <option value="2">失效</option>
			       </select>
			    </td>
			</tr>
			<tr> </tr>
         <tr>
             <td colspan="4">
                <table class="listTable" >
                    <tr>规则设置</tr>
                    <tr>
                        <th>ID</th>
                        <th>月份</th>
                        <th>获取方式</th>
                        <th>投资区间</th>
                        <th>奖池</th>
                    </tr>
                    <#--<c:forEach items="${ruleList}"  var="rule">
                    <tr>
                        <td>${rule.id}</td>
                        <td>
                        	&lt;#&ndash;<c:if test="${not empty rule.investMonth}">${rule.investMonth} 月</c:if>&ndash;&gt;
                            <#if rule.investMonth ??>${rule.investMonth} 月</#if>
                        </td>
                        <td>
                        	${rule.investAmountCheckType}
                        </td>
                        <td>
	                       ${rule.investAmountText}
                        </td>
                        <td>${rule.ticketId} | ${rule.ticketTitle} | ${rule.ticketTypeText}</td>
                        </tr>
                    </c:forEach>-->

                    <#if ruleList ?? >
					 <#list ruleList as rule>
                        <tr>
                            <td>${rule.id}</td>
                            <td>
							<#--<c:if test="${not empty rule.investMonth}">${rule.investMonth} 月</c:if>-->
							<#if rule.investMonth ??>${rule.investMonth} 月</#if>
                            </td>
                            <td>
							${rule.investAmountCheckType}
                            </td>
                            <td>
							${rule.investAmountText}
                            </td>
                            <td>${rule.ticketId} | ${rule.ticketTitle} | ${rule.ticketTypeText}</td>
                        </tr>
					 </#list>
                    </#if>
                    
                </table>
                </td>
         </tr>
         <tr> </tr>
			<tr>
			    <td align="center" colspan="4">
			    	<a href="#" id="edit_activity_submit" onclick="return updateActivitySubmit();" name="change-permission" class="easyui-linkbutton" iconcls="icon-ok">确 定</a> 
			        	&nbsp;&nbsp;
			<a href="#" id="editActivityCancel" onclick="return editActivityCancel();" name="cancle-permission" class="easyui-linkbutton" iconcls="icon-cancel">取 消</a>
			    </td>
			</tr>
	   </table> 
	 </form>
<script>
	// 修改用户 取消
    function editActivityCancel() {
    	window.parent.closeDetailWin();
    }
	
	function updateActivitySubmit(){
		$.messager.progress({text:'执行中...'});
		$('#edit_activity_form').form('submit',{
            url: '/activity/updateActivity',
            onSubmit: function(){
            },
            success: function(result){
            	$.messager.progress('close'); 
            	var result = eval('('+result+')');
            	if (result.code == -1) {
    				$.messager.alert('错误',result.msg);
    			} else {
    				$.messager.alert('成功',"修改活动成功",'info',function(){
	    				window.parent.closeDetailWin();
    				});
    			}
            }
        });
    } 

	//初始化 显示方式 
	function initShow() {
		var editFlag = $("#editFlag").val();
		var tempStatus = $("#tempStatus").val();
		var lotteryTickets = "${lotteryTickets}";
		$("#ltTempStoreTR").hide();
		//将非状态 内容设置为 只读
		$("form input").prop("readonly", true);
   		
        //只允许修改状态
		if("SHOW" == editFlag){
			$("form textarea").prop("readonly", true);
			$("#edit_activity_submit").hide();
			$("#status").val(tempStatus);
    		$("#status").attr("disabled", "disabled");
		}else if("EDIT" == editFlag){
			$("form textarea").prop("readonly", false);
			$("#status").val(tempStatus);
		}
        //显示 已关联的列表
		$("#add_activity_Tab #ltTempStoreTR").before(lotteryTickets);
        
		var publishPlatforms = $("#publishPlatforms").val().split(",");
		for(var i = 0;i<publishPlatforms.length;i++){
			if(publishPlatforms[i]==1){
				$("#publishPlatforms1").attr("checked",true); 
			}else if(publishPlatforms[i]==2){
				$("#publishPlatforms2").attr("checked",true);
			}else if(publishPlatforms[i]==3){
				$("#publishPlatforms3").attr("checked",true);
			}
		}
		
		var borrowTypes = $("#borrowTypes").val().split(",");
		for(var i = 0;i<borrowTypes.length;i++){
			if(borrowTypes[i]==3){
				$("#borrowTypes1").attr("checked",true); 
			}else if(borrowTypes[i]==1){
				$("#borrowTypes2").attr("checked",true);
			}else if(borrowTypes[i]==2){
				$("#borrowTypes3").attr("checked",true);
			}else if(borrowTypes[i]==0){
				$("#borrowTypes4").attr("checked",true);
			}else if(borrowTypes[i]==5){
				$("#borrowTypes5").attr("checked",true);
			}else if(borrowTypes[i]==6){
				$("#borrowTypes6").attr("checked",true);
			}else if(borrowTypes[i]==8){
				$("#borrowTypes8").attr("checked",true);
			}else if(borrowTypes[i]==9){
				$("#borrowTypes9").attr("checked",true);
			}else if(borrowTypes[i]==99){
				$("#borrowTypes99").attr("checked",true);
			}
		}
		if($("#investType").val()==1){
			$("#investTypeName").val("单次投资");
		}else{
			$("#investTypeName").val("总投资");
		}
	}
	initShow();
</script>
</body>
</html>